package com.ss.android.article.common;

import android.animation.Animator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Shader;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

public class FeedFlashMaskView extends View {
    int a;
    private ValueAnimator b;
    private Paint c;
    private ValueAnimator.AnimatorUpdateListener d = new cc(this);

    public FeedFlashMaskView(Context context) {
        super(context);
        this.b();
    }

    public FeedFlashMaskView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        this.b();
    }

    public FeedFlashMaskView(Context context, @Nullable AttributeSet attrs, int defaultStyleAttrs) {
        super(context, attrs, defaultStyleAttrs);
        this.b();
    }

    public final void a() {
        if(this.b != null) {
            this.b.removeAllUpdateListeners();
            this.b.cancel();
        }
    }

    private void b() {
        this.c = new Paint();
        this.c.setAlpha(128);
        this.c.setAntiAlias(true);
        this.c.setDither(true);
        this.c.setFilterBitmap(true);
    }

    private Animator getShiningAnimator() {
        ValueAnimator v0;
        if(this.b != null) {
            v0 = this.b;
        }
        else {
            this.b = ValueAnimator.ofFloat(new float[]{0f, 1f});
            this.b.setDuration(2000);
            this.b.setFloatValues(new float[0]);
            this.b.setRepeatCount(-1);
            this.b.setRepeatMode(1);
            this.b.addUpdateListener(this.d);
            v0 = this.b;
        }

        return ((Animator)v0);
    }

    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        this.a();
    }

    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        this.c.setShader(new LinearGradient(((float)this.a), 0f, ((float)(this.a + this.getWidth())), ((float)this.getHeight()), new int[]{this.getResources().getColor(com.ss.android.article.browser.R.color.jb), this.getResources().getColor(com.ss.android.article.browser.R.color.feed_mask_view_bg_color)}, null, Shader.TileMode.MIRROR));
        canvas.drawRect(0f, 0f, ((float)this.getWidth()), ((float)this.getHeight()), this.c);
    }

    public void setVisibility(int arg2) {
        super.setVisibility(arg2);
        if(arg2 == 8) {
            this.a();
        }
    }
}

